package com.qunar.qcf.core.service;

import java.util.EventListener;

import com.qunar.qcf.core.session.IdleStatus;
import com.qunar.qcf.core.session.IoSession;

/**
 * Listens to events related to an {@link IoService}.
 *
 * 用于监听IoService相关事件
 */
public interface IoServiceListener extends EventListener {
    /**
     * Invoked when a new service is activated by an {@link IoService}.
     *
     * @param service the {@link IoService}
     * 激活一个新的Service
     */
    void serviceActivated(IoService service) throws Exception;
    
    /**
     * Invoked when a service is idle.
     * 当Service闲置时调用
     */
    void serviceIdle(IoService service, IdleStatus idleStatus) throws Exception;

    /**
     * Invoked when a service is deactivated by an {@link IoService}.
     *
     * @param service the {@link IoService}
     */
    void serviceDeactivated(IoService service) throws Exception;

    /**
     * Invoked when a new session is created by an {@link IoService}.
     *
     * @param session the new session
     * 当一个session会话挂起时调用
     */
    void sessionCreated(IoSession session) throws Exception;

    /**
     * Invoked when a session is being destroyed by an {@link IoService}.
     *
     * @param session the session to be destroyed
     * 当一个session会话摧毁时调用
     */
    void sessionDestroyed(IoSession session) throws Exception;
}
